package Day26;

public class copyPerson {

    public static void main(String[] args) {
        Person p1 = new Person("下周",34);
        Person p2 = new Person();
        A a = new A();
        p2 = a.ccopyPerson(p1);
        System.out.println(p2.getName() + " , " +p2.getAge());
    }


}


class Person{
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Person() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    public String toString(){
        return "name = " + name+ ", age = " + age;
    }
}

class A{
    public  Person ccopyPerson(Person p){
        Person temp = new Person();
        temp.setAge(p.getAge());
        temp.setName(p.getName());
        return temp;
    }
}